<?php /*
	
*/ ?>
<?php include("system/config.inc.php");
$donotinclude = 1;
if(!isset($_SESSION['adminuserid']))
{
	header("location:index.php?msg=logfirst");
	die();
}
include("inc/header.php");?>
<body>


<table width="80%" border="0" align="center" cellpadding="0" cellspacing="1" class="middlebackground">
  <tr>
    <td valign="top" align="center"><?php include(INC."top.inc.php");?></td>
  </tr>
  <tr valign="top">
    <td align="center">
	<br /><br />
	<table width="85%" border="0" cellpadding="2" cellspacing="2" class="border">
      <tr class="bg1">
        <td height="18" colspan="4" align="left"><strong>Best Viewed Products...</strong></td>
        </tr>
      <tr align="center">
        <td colspan="4" align="left">&nbsp;</td>
      </tr>
      <tr align="center">
         <?php 
	   $rows="";
	 if(isset($_REQUEST['page']) && ($_REQUEST['page'])!="")
	 {
	 	$rows=$_REQUEST['page'];
	 
	  }	
	  ?><form name="form1" action="" method="post">
              <td colspan="4" align="left">
			  
			  Row per Page:
                <select name="page" onChange="document.form1.submit();">
                  <option value="0"<?php if($rows=='0'){echo "selected";}else{echo "";}?>>All</option>
                  <option value="5"<?php if($rows=='5'){echo "selected";}else{echo "";}?>>5 Per Page</option>
                  <option value="10"<?php if($rows=='10'){echo "selected";}else{echo "";}?>>10 Per Page</option>
                  <option value="15"<?php if($rows=='15'){echo "selected";}else{echo "";}?>>15 Per Page</option>
                </select>				</td></form>
        </tr>
      <tr align="center" class="tblbg3">
        <td><strong>No. </strong></td>        
        <td><strong>Product Name </strong></td>
        <td><strong>Prouct Description </strong></td>
		<td>
		<?php if(isset($_REQUEST['sort']) && ($_REQUEST['sort'])=='alphaasc') { ?>
			<a  class="ab1" href="prodviewed.php?sort=alphadesc" title="Click Here for decending data">Total Views</a>
		<?php } else if(isset($_REQUEST['sort']) && ($_REQUEST['sort'])=='alphadesc') { ?>
			<a class="ab1" href="prodviewed.php?sort=alphaasc" title="Click Here for asscending data">Total Views</a>
		<?php } else { ?>
			 <a class="ab1" href="prodviewed.php?sort=alphadesc" title="Click Here for sorting data">Total Views</a>
		<?php } ?>
		 </td>
      </tr>
	  
	   <?php
		/**************************************
				PAGING CODE START
		**************************************/
		if(isset($_REQUEST['page']) && ($_REQUEST['page'])!=0)
			{
				$rows=$_REQUEST['page'];
				$rowperpage=$rows;
			}else{$rowperpage=$rows=10000;}
			$tablename="tblproddesc";
			$per_page_keywords= "intprodviewed >= 0";
			$per_page_sorts= "";
			$wvar = "";
			include("system/paging.inc.php");

		/**************************************
				PAGING CODE ENDING
		**************************************/
		//echo $_REQUEST['sort'];
	if(isset($_REQUEST['sort']) && ($_REQUEST['sort'])=='alphaasc')
		{
			$sql="select * from tblproddesc ORDER BY `intprodviewed` ASC Limit ".($page_no*$row_per_page).",".$row_per_page;
			//$result=$obj_db->select($sql);
			//print_r($result);
		//	echo $sql;
		}
		else if(isset($_REQUEST['sort']) && ($_REQUEST['sort'])=='alphadesc')
		{
   		$sql="select * from tblproddesc ORDER BY `intprodviewed` DESC Limit ".($page_no*$row_per_page).",".$row_per_page;
	//	echo $sql;
		}
		else
		{
		$sql="select * from tblproddesc Limit ".($page_no*$row_per_page).",".$row_per_page;
		//echo $sql;
		}
	
	//$sql = "select * from  ".$tablename."	where ".$per_page_keywords." Limit ".($page_no*$row_per_page).",".$row_per_page;
	$result = $obj_db->select($sql);
	if($result)
	{
		$pgno = $page_no*$row_per_page;
		$i=0;
		for($j=0;$j<count($result);$j++)
		 { 
			$screen_id=$result[$j]['intid'];
			 $i=$i+1;			
		  ?>
	  
      <tr align="center" class="<?php echo ($i%2==0)?"Hrnormal":"Hralter"; ?>" onMouseOver="this.className='Hrhover';" onMouseOut="this.className='<?php echo ($i%2==0)?"Hrnormal":"Hralter"; ?>';">        
        <td><?php echo $i+$pgno; ?>.</td>
		<td><a href="proddetails.php?prod=<?php echo $screen_id;?>" style="cursor:hand" class="aa"><?php echo stripslashes($result[$j]['varprodname']); ?></a></td>
        <td><?php
				  $desctxt=$result[$j]['txtdesc'];

				 if(strlen($desctxt) > 15 )

				  {
				  	$desctxt=substr($desctxt,0,15);

					$desctxt=$desctxt."...";
				  }			  

				  echo srchwordchangestyl($desctxt);
			?></td>
			<td><?php echo stripslashes($result[$j]['intprodviewed']); ?></td>
      </tr>
	  <?php } } ?>

      <tr>       
	          <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
		<td>&nbsp;</td>
      </tr>
	  
      <tr align="center">        
        <td colspan="4"><?php pagindet_atbotttom_page($div_page_no,$page_no,$req_querystr,$total_db_rec,$row_per_page); ?></td>
        </tr>
    </table></td>
  </tr>
  
  
  <tr>
    <td align="center"><?php include(INC."bottom.php");?></td>
  </tr>
</table>

</body>
</html>
